<?php

namespace App\Api;

use PhalApi\Api;


/**
 * 万国觉得token
 * @author: dogstar <chanzonghuang@gmail.com> 2014-10-04
 */
class RokId extends Api
{

    public function getRules()
    {
        return array(
            'id' => array(),
        );
    }

    /**
     * rok-token
     * @desc 多条件查询接口
     * @return array data 被查数据
     * @exception 400 非法请求，参数传递错误
     */
    public function id()
    {
        header('Access-Control-Allow-Origin:*');
        $cardinfo = \PhalApi\DI()->notorm
            ->rok_card
            ->where('used', 'no')
            ->fetchOne();

        if ($cardinfo) {
            \PhalApi\DI()->notorm
                ->rok_card
                ->where('id', $cardinfo['id'])
                ->update(array(
                    'used' => 'used',
                    'time' => date('Y-m-d H:i:s', time())
                ));
        }
        return $cardinfo;
    }


}
